package com.design.observer.service;

import java.util.Observable;

/**
 * @author zhengzihong
 * @version 1.0.0
 * @date 2018/9/10
 * @Description
 */
public class NewWeatherData extends Observable{

    private float temperature;

    private float humidity;

    private float pressure;



    /**
     * 当从气象站得到更新观测值，我们通知观察者
     */
    public void measurementsChanged(){
        setChanged();
        notifyObservers();
    }


    /**
     * 塞入最新数据
     * @param temperature
     * @param humidity
     * @param pressure
     */
    public void setMeasurements(float temperature, float humidity, float pressure){
        this.temperature = temperature;
        this.humidity = humidity;
        this.pressure = pressure;
        measurementsChanged();
    }

    public float getTemperature() {
        return temperature;
    }

    public float getHumidity() {
        return humidity;
    }

    public float getPressure() {
        return pressure;
    }
}
